package com.whosly.mysql.protocol.packet.impl.ok.data;

import java.io.Serializable;

/**
 * @author 风杨
 * @see <a href="yueny09@163.com">mailTo: yueny09@163.com</a>
 */
class ReadSizeItemFormat implements Serializable {
    // readByteSize 读取大小, readByteSizeAtTime
    // rowInSec 行读速度      kibInSec 行读大小
    private static final String READ_SIZE_FORMAT = "%s B in %s sec,. ";
    private static final String ROW_IN_SEC_FORMAT = "%s rows/sec,. ";
    private static final String KIB_IN_SEC_FORMAT = "%s B/sec,. ";

    public static final String format(Long readByteSize, String readByteSizeAtTime,
                                      Double rowInSec, Integer kibInSec){
        String readSizeVal = "";
        if(readByteSize != null && readByteSizeAtTime != null){
            readSizeVal = String.format(READ_SIZE_FORMAT, readByteSize, readByteSizeAtTime);
        }

        String rowInSecVal = "";
        if(rowInSec != null) {
            rowInSecVal = String.format(ROW_IN_SEC_FORMAT, rowInSec);
        }

        String kibInSecVal = "";
        if(kibInSec != null) {
            kibInSecVal = String.format(KIB_IN_SEC_FORMAT, kibInSec);
        }

        return readSizeVal + rowInSecVal + kibInSecVal;
    }

}

